package notification

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'GET'
        url("/api/notifications/users/1") {
            queryParameters {
                parameter("status", "unRead")
            }
        }
    }
    response {
        status 200
        headers {
            contentType(applicationJsonUtf8())
        }
        body("""
             [{
                    "id":1,
                    "senderId":5,
                    "receiverId":1,
                    "isRead":0,
                    "message":"hello,world2!",
                    "url":"http://www.csdn.com",
                    "createTime":"2018-09-27",
                    "type":"STUDENT_MODIFY_ASSIGNMENT_STATUS",
             }]
        """)
        bodyMatchers {
            jsonPath('$.[*]', byType())
            jsonPath('$.[*].id', byRegex(number()))
            jsonPath('$.[*].senderId', byRegex(number()))
            jsonPath('$.[*].receiverId', byRegex(number()))
            jsonPath('$.[*].isRead', byRegex(anyBoolean()))
            jsonPath('$.[*].url', byRegex(nonEmpty()))
            jsonPath('$.[*].createTime', byRegex(nonEmpty()))
            jsonPath('$.[*].type', byRegex(nonEmpty()))
        }
    }
}
